home *** CD-ROM | disk | FTP | other *** search
- unit NameSpc2U;
-
- {$ifdef Ver90} { Delphi 2.0x }
- {$define DelphiLessThan3}
- {$define DelphiLessThan4}
- {$define DelphiLessThan5}
- {$endif}
- {$ifdef Ver93} { C++ Builder 1.0x }
- {$define DelphiLessThan3}
- {$define DelphiLessThan4}
- {$define DelphiLessThan5}
- {$endif}
- {$ifdef Ver100} { Delphi 3.0x }
- {$define DelphiLessThan4}
- {$define DelphiLessThan5}
- {$endif}
- {$ifdef Ver110} { C++ Builder 3.0x }
- {$define DelphiLessThan4}
- {$define DelphiLessThan5}
- {$endif}
- {$ifdef Ver120} { Delphi 4.0x }
- {$define DelphiLessThan5}
- {$endif}
- {$ifdef Ver125} { C++Builder 4.0x }
- {$define DelphiLessThan5}
- {$endif}
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, ComCtrls;
-
- type
- TForm1 = class(TForm)
- btnInternetCache: TButton;
- btnRecycledBin: TButton;
- lstSpecialFolder: TListBox;
- lvFolderContents: TListView;
- procedure FormCreate(Sender: TObject);
- procedure btnInternetCacheClick(Sender: TObject);
- procedure btnRecycledBinClick(Sender: TObject);
- procedure lstSpecialFolderClick(Sender: TObject);
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- uses
- {$ifdef DelphiLessThan3}
- OleAuto, Ole2,
- {$else}
- ComObj,
- {$endif}
- NameHlp2U, ShlObj;
-
- {$R *.DFM}
-
- {$ifdef DelphiLessThan4}
- const
- CSIDL_INTERNET = $0001;
- CSIDL_ALTSTARTUP = $001d; // DBCS
- CSIDL_COMMON_ALTSTARTUP = $001e; // DBCS
- CSIDL_COMMON_FAVORITES = $001f;
- CSIDL_INTERNET_CACHE = $0020;
- CSIDL_COOKIES = $0021;
- CSIDL_HISTORY = $0022;
- {$endif}
- {$ifdef DelphiLessThan3}
- const
- CSIDL_COMMON_STARTMENU = $0016;
- CSIDL_COMMON_PROGRAMS = $0017;
- CSIDL_COMMON_STARTUP = $0018;
- CSIDL_COMMON_DESKTOPDIRECTORY = $0019;
- CSIDL_APPDATA = $001a;
- CSIDL_PRINTHOOD = $001b;
- {$endif}
-
- type
- TFolder = record
- Name: String;
- ID: Cardinal;
- end;
- const
- Folders: array[0..29] of TFolder = (
- (Name: 'CSIDL_DESKTOP'; ID: CSIDL_DESKTOP),
- (Name: 'CSIDL_INTERNET'; ID: CSIDL_INTERNET),
- (Name: 'CSIDL_PROGRAMS'; ID: CSIDL_PROGRAMS),
- (Name: 'CSIDL_CONTROLS'; ID: CSIDL_CONTROLS),
- (Name: 'CSIDL_PRINTERS'; ID: CSIDL_PRINTERS),
- (Name: 'CSIDL_PERSONAL'; ID: CSIDL_PERSONAL),
- (Name: 'CSIDL_FAVORITES'; ID: CSIDL_FAVORITES),
- (Name: 'CSIDL_STARTUP'; ID: CSIDL_STARTUP),
- (Name: 'CSIDL_RECENT'; ID: CSIDL_RECENT),
- (Name: 'CSIDL_SENDTO'; ID: CSIDL_SENDTO),
- (Name: 'CSIDL_BITBUCKET'; ID: CSIDL_BITBUCKET),
- (Name: 'CSIDL_STARTMENU'; ID: CSIDL_STARTMENU),
- (Name: 'CSIDL_DESKTOPDIRECTORY'; ID: CSIDL_DESKTOPDIRECTORY),
- (Name: 'CSIDL_DRIVES'; ID: CSIDL_DRIVES),
- (Name: 'CSIDL_NETWORK'; ID: CSIDL_NETWORK),
- (Name: 'CSIDL_NETHOOD'; ID: CSIDL_NETHOOD),
- (Name: 'CSIDL_FONTS'; ID: CSIDL_FONTS),
- (Name: 'CSIDL_TEMPLATES'; ID: CSIDL_TEMPLATES),
- (Name: 'CSIDL_COMMON_STARTMENU'; ID: CSIDL_COMMON_STARTMENU),
- (Name: 'CSIDL_COMMON_PROGRAMS'; ID: CSIDL_COMMON_PROGRAMS),
- (Name: 'CSIDL_COMMON_STARTUP'; ID: CSIDL_COMMON_STARTUP),
- (Name: 'CSIDL_COMMON_DESKTOPDIRECTORY'; ID: CSIDL_COMMON_DESKTOPDIRECTORY),
- (Name: 'CSIDL_APPDATA'; ID: CSIDL_APPDATA),
- (Name: 'CSIDL_PRINTHOOD'; ID: CSIDL_PRINTHOOD),
- (Name: 'CSIDL_ALTSTARTUP'; ID: CSIDL_ALTSTARTUP),
- (Name: 'CSIDL_COMMON_ALTSTARTUP'; ID: CSIDL_COMMON_ALTSTARTUP),
- (Name: 'CSIDL_COMMON_FAVORITES'; ID: CSIDL_COMMON_FAVORITES),
- (Name: 'CSIDL_INTERNET_CACHE'; ID: CSIDL_INTERNET_CACHE),
- (Name: 'CSIDL_COOKIES'; ID: CSIDL_COOKIES),
- (Name: 'CSIDL_HISTORY'; ID: CSIDL_HISTORY));
-
- procedure TForm1.FormCreate(Sender: TObject);
- var
- Loop: Cardinal;
- begin
- for Loop := Low(Folders) to High(Folders) do
- lstSpecialFolder.Items.AddObject(
- Folders[Loop].Name, TObject(Folders[Loop].ID))
- end;
-
- const
- {$ifdef DelphiLessThan3}
- IID_InternetExplorerCache: TGUID = (
- D1:$7BD29E00;D2:$76C1;D3:$11CF;D4:($9D,$D0,$00,$A0,$C9,$03,$49,$33));
- IID_RecycleBin: TGUID = (
- D1:$645FF040;D2:$5081;D3:$101B;D4:($9F,$08,$00,$AA,$00,$2F,$95,$4E));
- {$else}
- IID_InternetExplorerCache: TGUID = '{7BD29E00-76C1-11CF-9DD0-00A0C9034933}';
- IID_RecycleBin: TGUID = '{645FF040-5081-101B-9F08-00AA002F954E}';
- {$endif}
-
- procedure TForm1.btnInternetCacheClick(Sender: TObject);
- begin
- GetFolderItems(
- CreateFolderObject(
- GetSpecialFolderClsID('Cache')), lvFolderContents.Items)
- end;
-
- procedure TForm1.btnRecycledBinClick(Sender: TObject);
- begin
- GetFolderItems(
- CreateFolderObject(IID_RecycleBin), lvFolderContents.Items)
- end;
-
- procedure TForm1.lstSpecialFolderClick(Sender: TObject);
- begin
- Caption := GetSpecialFolderLocation(
- Cardinal(lstSpecialFolder.Items.Objects[lstSpecialFolder.ItemIndex]))
- end;
-
- end.
-